<?php
declare(strict_types=1);
namespace App\Utils\Other\Payment\Neopay;

use function Hyperf\Config\config;

Class Wechat extends App {

    /**
     * 支付
     * @param array $params
     * @return array
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function pay(array $params)
    {
        $this->setConfig(['path' => 'api/transactions/scan_payment/wechat/code/create']);

        [$accessToken,] = $this->accessToken();
        $params['encryptInfo'] = [
            'loginId' => $this->getConfig('login_id'),
            'accessToken' => $accessToken
        ];
        $params['version'] = '2.0';
        $params['data']['appId'] = $this->getConfig('jump', false) === false?
            $this->getConfig('app_id'):
            config('cloud.mini.app_id');

        return $this->request($params);
    }
}